<html> 
<head> 
<title> </title>
<style> 
px {font-family: "Lucida Console", Monaco }
p { font-size:100%; line-height:1.1em; }
body {xfont-style: sans-serif}
body {
color:#333; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:1em; line-height:1.3em; }
a:visited { color:#666; }
h1,h2,h3,h4,h5,h6 { color:#333; font-family:georgia, verdana, sans-serif; }
h1 { font-size:150%; page-break-before:auto;background-color: #aaaaff}
h2 { font-size:143%;color:teal; }
h3 { font-size:134%;color:blue; }
h4 { font-size:120%;color:gray; }
img { max-width: 55em}
p{ padding: 0;margin:0; }
p{ padding-right:1.4em; }
p{ padding-bottom:0.1em; }
p{ padding-top:1em; }
p{ whitespace: pre-wrap; }
h5,h6 { font-size:100% }
a.nav,a:link.nav, a:visited.nav { background-color:#FFF; color:#000; }
XXtable { border:double #000; border-collapse:collapse; }
XXtable { border-collapse:collapse; }
XXtd { border:thin solid #888; }
XXtd { border:none; }
li { margin-bottom:0.5em; }
blockquote { display:block; font-size:100%; line-height:1.1em; margin:0 0 0.5em; padding:0 2.5em; }
pre { background-color:#DDD; font-size:100%; overflow:auto; padding:1em; }
a,li span { color:#000; }
a:hover, a.nav:hover, a:hover math { background-color:#000; color:#FFF; }
#Container { margin:0 10px; text-align:center; background-color: #BBB}
#Content { border-top:none; margin:auto; padding:0.3em; text-align:left; width:100%; max-width:55em; background:#FFF}
span.webName { font-size:.5em; }
textarea#content { font-size: 1em; line-height: 1.125; }
h1#pageName { line-height:1em; margin:0.2em 0 0.2em 0; padding:0; }
.property { color:#666; font-size:100%; }
a.existingWikiWord[title]{ //border: 1px dashed #BBB; }
.byline { color:#666; font-size:1.0em; font-style:italic; margin-bottom:1em; padding-top:1px; } 
</style> 
</head>
<BODY bgcolor=#F0F0F0 text=#000000 link=#0000ff vlink=#C000C0 alink=#ff0000><A NAME=top></A>
<h5><a href="https://github.com/urbanjost/M_strings">[UP]</a></h5>
<div id="Container">
<div id="Content">
<CENTER>
<H1><HR><I>Manual Reference Pages &nbsp;-&nbsp;</I><NOBR>delim (3m_strings)</NOBR><HR></H1>
</CENTER>
<A name=0>

     <H3>NAME</H3>

</A>
<BLOCKQUOTE>
<B>delim</B>(3f) - [M_strings:TOKENS] parse a string and store tokens into
an array
(LICENSE:PD)
<P>
</BLOCKQUOTE>
<A name=contents></A><H3>CONTENTS</H3></A>
<BLOCKQUOTE>
<A HREF=#1>Synopsis</A><BR>
<A HREF=#2>Description</A><BR>
<A HREF=#3>Options</A><BR>
<A HREF=#4>Examples</A><BR>
<A HREF=#5>Author</A><BR>
<A HREF=#6>License</A><BR>
</BLOCKQUOTE>
<A name=7>

     <H3>SYNOPSIS</H3>

</A>
<BLOCKQUOTE>
subroutine <B>delim</B>(line,array,n,icount,ibegin,iterm,lgth,dlim)
<P>
<PRE>
    character(len=*),intent(in)  :: line
    integer,integer(in)          :: n
    integer,intent(out)          :: icount
    character(len=*)             :: array(n)
    integer,intent(out)          :: ibegin(n)
    integer,intent(out)          :: iterm(n)
    integer,intent(out)          :: lgth
    character(len=*)             :: dlim
<P>
</PRE>
</BLOCKQUOTE>
<A name=2>

     <H3>DESCRIPTION</H3>

</A>
<BLOCKQUOTE>
Given a LINE of structure " par1 par2 par3 &#46;&#46;&#46; parn "
store each <B>par</B>(n) into a separate variable in ARRAY (UNLESS
<B>ARRAY</B>(1).eq.&#146;#N#&#146;)
<P>
Also set ICOUNT to number of elements of array initialized, and
return beginning and ending positions for each element in <B>IBEGIN</B>(N)
and <B>ITERM</B>(N).
<P>
Return position of last non-blank character (even if more
than N elements were found) in lgth
<P>
No quoting or escaping of delimiter is allowed, so the delimiter
character can not be placed in a token.
<P>
No checking for more than N parameters; If any more they are ignored.
</BLOCKQUOTE>
<A name=3>

     <H3>OPTIONS</H3>

</A>
<BLOCKQUOTE>
<TABLE cellpadding=3>
<TR valign=top><TD width=6% nowrap>
<B>LINE</B> </TD><TD valign=bottom>
input string to parse into tokens
</TD></TR>
<TR valign=top><TD colspan=2>
<B></B><B>ARRAY</B>(N) </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
array that receives tokens
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>N</B> </TD><TD valign=bottom>
size of arrays ARRAY, IBEGIN, ITERM
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>ICOUNT</B> </TD><TD valign=bottom>
number of tokens found
<B>IBEGIN</B>(N) starting columns of tokens found
</TD></TR>
<TR valign=top><TD colspan=2>
<B></B><B>ITERM</B>(N) </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
ending columns of tokens found
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>LGTH</B> </TD><TD valign=bottom>
position of last non-blank character in input string LINE
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>DLIM</B> </TD><TD valign=bottom>
delimiter characters
</TD></TR>
<TR></TR></TABLE></BLOCKQUOTE>
<A name=4>

     <H3>EXAMPLES</H3>

</A>
<BLOCKQUOTE>
Sample program:
<P>
<PRE>
    program demo_delim
<P>
    use M_strings, only: delim
    implicit none
    character(len=80) :: line
    character(len=80) :: dlm
    integer,parameter :: n=10
    character(len=20) :: array(n)=&#146; &#146;
    integer           :: ibegin(n),iterm(n)
    integer           :: i20, icount, lgth, i10
    line=&#146; first  second 10.3 words_of_stuff  &#146;
    do i20=1,4
       ! change delimiter list and what is calculated or parsed
       if(i20.eq.1)dlm=&#146; &#146;
       if(i20.eq.2)dlm=&#146;o&#146;
       if(i20.eq.3)dlm=&#146; aeiou&#146;    ! NOTE SPACE IS FIRST
       if(i20.eq.3)ARRAY(1)=&#146;#N#&#146;  ! QUIT RETURNING STRING ARRAY
       if(i20.eq.4)line=&#146;AAAaBBBBBBbIIIIIi  J K L&#146;
<P>
       ! write out a break line composed of =========== ..
       write(*,&#146;(57("="))&#146;)
       ! show line being parsed
       write(*,&#146;(a)&#146;)&#146;PARSING=[&#146;//trim(line)//&#146;] on &#146;//trim(dlm)
       ! call parsing procedure
       call delim(line,array,n,icount,ibegin,iterm,lgth,dlm)
       write(*,*)&#146;number of tokens found=&#146;,icount
       write(*,*)&#146;last character in column &#146;,lgth
       if(icount.gt.0)then
          if(lgth.ne.iterm(icount))then
             write(*,*)&#146;ignored from column &#146;,iterm(icount)+1,&#146; to &#146;,lgth
          endif
          do i10=1,icount
             ! check flag to see if ARRAY() was set
             if(array(1).ne.&#146;#N#&#146;)then
                ! from returned array
                write(*,&#146;(a,a,a)&#146;,advance=&#146;no&#146;)&
                &&#146;[&#146;,array(i10)(:iterm(i10)-ibegin(i10)+1),&#146;]&#146;
             endif
          enddo
          ! using start and end positions in IBEGIN() and ITERM()
          write(*,*)
          do i10=1,icount
             ! from positions in original line
             write(*,&#146;(a,a,a)&#146;,advance=&#146;no&#146;)&
             &&#146;[&#146;,line(ibegin(i10):iterm(i10)),&#146;]&#146;
          enddo
          write(*,*)
       endif
    enddo
    end program demo_delim
<P>
</PRE>
<BLOCKQUOTE>
Results:
<P>
<PRE>
   =========================================================
   PARSING=[ first  second 10.3 words_of_stuff] on
    number of tokens found=           4
    last character in column           34
   [first][second][10.3][words_of_stuff]
   [first][second][10.3][words_of_stuff]
   =========================================================
   PARSING=[ first  second 10.3 words_of_stuff] on o
    number of tokens found=           4
    last character in column           34
   [ first  sec][nd 10.3 w][rds_][f_stuff]
   [ first  sec][nd 10.3 w][rds_][f_stuff]
   =========================================================
   PARSING=[ first  second 10.3 words_of_stuff] on  aeiou
    number of tokens found=          10
    last character in column           34
<P>
   [f][rst][s][c][nd][10.3][w][rds_][f_st][ff]
   =========================================================
   PARSING=[AAAaBBBBBBbIIIIIi  J K L] on  aeiou
    number of tokens found=           5
    last character in column           24
<P>
   [AAA][BBBBBBbIIIII][J][K][L]
<P>
</PRE>
</BLOCKQUOTE>
</BLOCKQUOTE>
<A name=5>

     <H3>AUTHOR</H3>

</A>
<BLOCKQUOTE>
John S. Urban
</BLOCKQUOTE>
<A name=6>

     <H3>LICENSE</H3>

</A>
<BLOCKQUOTE>
Public Domain
</BLOCKQUOTE>
<P><HR>
<TABLE width=100%><TR> <TD width=33%><I>Nemo Release 3.1</I></TD> <TD width=33% align=center>delim (3m_strings)</TD> <TD align=right width=33%><I>April 30, 2022</I></TD> </TR></TABLE><FONT SIZE=-1>Generated by <A HREF="http://www.squarebox.co.uk/download/manServer.shtml">manServer 1.08</A> from d5edbf84-f950-4b6f-b850-f332e47cf5b4 using man macros.</FONT>
<br><br><center><img src="images/delim.gif"></center>
</div>
</div>
</body>
</HTML>
